
// Copyright (c) 2002 HTHK
package admin.system.role;

import javax.servlet.*;
import javax.servlet.http.*;

import java.io.*;
import java.sql.*;

import com.ffpc.servlet.*;
import com.ffpc.sql.*;
import com.ffpc.struts.StrutsMessage;

/**
 * A Class class.
 * <P>
 * @author HTHK
 */
public class RoleSearch
  extends DBServlet {

  @Override
protected String perform(  HttpServletRequest request,
                             HttpServletResponse response,
                             StrutsMessage message)
    throws  ServletException,
            IOException,
            SQLException,
            DataException,
            Exception
  {
      RoleBean role = RoleProcess.createBean();
      role.setRole_id(request.getParameter("role_id"));
      role.setRole_name(request.getParameter("role_name"));
      role.setRole_des(request.getParameter("role_des"));
      RoleBean[] roles = RoleProcess.find(this.getConnection(),role);
      if (roles==null || roles.length==0)
      {
          message.setMessage("No record, please input another criteria.");
          return "system/RoleSearch.jsp";
      }
      else if (roles.length==1)
      {
          request.setAttribute("role",roles[0]);
          return "system/Role.jsp?formAction=Update";
      }
      else
      {
          request.setAttribute("roles",roles);
          return "system/RoleList.jsp";
      }
  }
}


